/*
 * ComponentBase.java
 *
 * Created on September 2, 2006, 4:09 PM
 *
 * (C) 2006 R. Alexander Milowski
 */

package org.infoset.component;

import java.net.URI;
import org.infoset.xml.Document;
import org.infoset.xml.ItemDestination;
import org.infoset.xml.Name;
import org.infoset.xml.XMLException;

/**
 *
 * @author alex
 */
public class ComponentBase implements Component {

   protected Name name;
   protected String vendor;
   protected String version;
   protected Context context;
   
   /** Creates a new instance of ComponentBase */
   protected ComponentBase(Name name) {
      this(name,null,null);
   }
   
   protected ComponentBase(Name name,String vendor,String version)
   {
      this.name = name;
      this.vendor = vendor;
      this.version = version;
   }
   
   public void init(Context context)
      throws XMLException
   {
      this.context = context;
   }

   public void bindResource(Name port,Document document)
      throws XMLException
   {
      throw new XMLException("Input port "+port+" unknown and cannot be bound as a resource.");
   }
   
   public void bindResource(Name port,URI location)
      throws XMLException
   {
      throw new XMLException("Input port "+port+" unknown and cannot be bound as a resource.");
   }
   
   public void bindOutputPort(Name port,ItemDestination output)
      throws XMLException
   {
      throw new XMLException("Output port "+port+" unknown.");
   }
   
   public void onStart()
      throws XMLException
   {
      
   }
   
   public ItemDestination getInputPort(Name port)
      throws XMLException
   {
      throw new XMLException("Input port "+port+" unknown.");
   }

   public void onDocumentInput(Name port,Document doc)
      throws XMLException
   {
      throw new XMLException("Input port "+port+" unknown.");
   }
   
   public void onEnd()
      throws XMLException
   {
      
   }
}
